From: Florian Müllner Date: Fri, 17 Jan 2014 14:54:14 +0000 (-0500) Subject: switcherPopup: Fix spacing calculation for empty lists X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~2889 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=427790f005f8094d9d9495786ed5ed5ff2114689;p=gnome-shell.git switcherPopup: Fix spacing calculation for empty lists Without special-casing, our current spacing calculation results in negative size requests for empty lists, which will trigger a Clutter assert later. While the list is never supposed to be empty, bugs happen; crashing users' systems is the least graceful way of handling this, so don't do it. https://bugzilla.gnome.org/show_bug.cgi?id=722434 --- diff --git a/js/ui/switcherPopup.js b/js/ui/switcherPopup.js index 3b1532f33..176bc6aba 100644 --- a/js/ui/switcherPopup.js +++ b/js/ui/switcherPopup.js @@ -513,7 +513,7 @@ const SwitcherList = new Lang.Class({ _getPreferredWidth: function (actor, forHeight, alloc) { let [maxChildMin, maxChildNat] = this._maxChildWidth(forHeight); - let totalSpacing = this._list.spacing * (this._items.length - 1); + let totalSpacing = Math.max(this._list.spacing * (this._items.length - 1), 0); alloc.min_size = this._items.length * maxChildMin + totalSpacing; alloc.natural_size = alloc.min_size; this._minSize = alloc.min_size; @@ -543,7 +543,7 @@ const SwitcherList = new Lang.Class({ let childHeight = box.y2 - box.y1; let [maxChildMin, maxChildNat] = this._maxChildWidth(childHeight); - let totalSpacing = this._list.spacing * (this._items.length - 1); + let totalSpacing = Math.max(this._list.spacing * (this._items.length - 1), 0); let childWidth = Math.floor(Math.max(0, box.x2 - box.x1 - totalSpacing) / this._items.length);